package ils.services;


import ils.domain.issue.model.Issue;
import ils.domain.issue.model.Reserve;
import ils.util.HibernateSession;
import ils.util.HibernateSessionManager;
import ils.util.SpringUtil;
import junit.framework.Assert;
import org.junit.Test;
import org.springframework.context.ApplicationContext;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: rejeevd
 * Date: 6/10/12
 * Time: 7:44 PM
 * To change this template use File | Settings | File Templates.
 */
public class IssueServiceTest
{
    private ApplicationContext context = SpringUtil.getApplicationContext();
    private IssueService issueService = (IssueService)context.getBean("issueService");

    @Test
    public void testReserve()
    {
        Reserve reserve = issueService.request(1, 3);
        Assert.assertNotNull(reserve.getId());
    }

    @Test
    public void testIssue()
    {
        try{issueService.release("11111", 3);}catch (Exception e){}
        Issue issue = issueService.issue("11111", 3);
        Assert.assertNotNull(issue);
    }

    @Test
    public void testIssueHistoryForABook()
    {
        List<Issue> issues = issueService.getIssuesForABook(1, 0, 10);
        Assert.assertNotNull(issues);
        Assert.assertNotSame(0, issues.size());
    }
}
